<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<s:include value="/comm/header.jsp" />
<s:include value="/comm/menu.jsp" />
<!--第2部分开始  -->
<div class="wrap1">
	<div class="blank1"></div>

	<div class="top3">

		<!--左边开始  -->
		<div class="wrap_left">
			<div class="w_box4">


				<div class="detail_box">


					<div class="wrap_left">
						<div class="content7_1">
							<s:if test="wantBuyModel.absoluteImagePath != null">
								<img src="<s:property value='wantBuyModel.image200' />" />
							</s:if>
						</div>
					</div>
					<div class="wrap_left">
						<div class="detail_tt">
							<s:property value='wantBuyModel.goodsName' />
						</div>
						<!-- -->
						<div class="content7_3">

							<div class="wrap_left">
								<div class="t1">

									<ul>
										<li><strong>类别：</strong>
											<s:property value='wantBuyModel.categoryName' />
										</li>
										

										<li><strong>物品价格：</strong><span class="span2">￥<s:property
													value='wantBuyModel.price' /></span> 左右</li>

										<li><strong>要求提供的单椐类型：</strong> 
												<s:if test="wantBuyModel.receipts == 0">不限</s:if> 
												<s:elseif test="wantBuyModel.receipts == 1">小票</s:elseif> 
												<s:elseif test="wantBuyModel.receipts == 2">发票</s:elseif> 
												<s:elseif test="wantBuyModel.receipts == 3">发票或小票</s:elseif>
												<s:else>小票或发票复印件</s:else>
										</li>
										
										
										<li><strong>数量：</strong>
											<s:property value='wantBuyModel.number' />
										</li>
										
										<li><strong>发布人：</strong>
											<s:property value="wantBuyModel.user.nickName" />
										</li>
										
									</ul>
								</div>

							</div>
							<div class="wrap_left">
								<div class="t2">

									<ul>
										<li><strong>目前已有<s:property value="wantBuyModel.total" />人求购</strong></li>
										<li><strong>所属区域：</strong>
										<s:property value='wantBuyModel.areaName' /></li>

										<li><strong>要求来源：</strong> <s:if
												test="wantBuyModel.source == 0">不限</s:if> <s:elseif
												test="wantBuyModel.source == 1">大型超市</s:elseif> <s:elseif
												test="wantBuyModel.source==2">便利店</s:elseif> <s:elseif
												test="wantBuyModel.source==3">专卖店</s:elseif> <s:elseif
												test="wantBuyModel.source==4">生产厂家</s:elseif> <s:else>其他</s:else>
										</li>

										<li><strong>可接受的代购服务费：</strong><span class="span19">￥<s:property
													value='wantBuyModel.serviceFee' />
										</span></li>

										<li><strong>信息有效期：</strong>
										<s:property value='wantBuyModel.validityPeriod' /></li>
	
									</ul>
								</div>


							</div>

							<div class="clear"></div>

						</div>
						<!-- -->
						<s:if test="#session.user == null || wantBuyModel.user.userid != #session.user.userid">
							<div class="wrap_left" id="inviteDiv">
								<span class="span30"><a id="invite" href="javascript:invite(<s:property value='wantBuyModel.wantId' />, <s:property value='wantBuyModel.user.userid' />);">发起代购邀约</a><br/></span>
							</div>
							<div class="wrap_left" id="rideBuyDiv">
								<div style="margin-left: 50px">
									<span class="span31 qiugou"><a href="javascript:rideBuy(<s:property value='wantBuyModel.wantId' />, <s:property value='wantBuyModel.user.userid' />);">搭车求购</a></span>
								</div>
							</div>
						</s:if>

					</div>
					<div class="clear"></div>
				</div>


				<div class="blank1"></div>




				<!--选项卡开始-->
				<div id="mainTabbox">
					<div id="tabbox1">
						<ul>
							<li id="taba1" onclick="setTab('taba',1,2)" class="hover"><a>详细描述</a></li>
							<li id="taba2" onclick="javascript:querySimpleBuys(<s:property value='wantBuyModel.wantId' />)"><a>搭车求购记录</a></li>
						</ul>

					</div>
					<div id="conten">
						<div>
							<div class="tab_show" id="con_taba_1">
								<s:property value="wantBuyModel.description" />
							</div>
							<div class="tab_show" id="con_taba_2">

								<!--列表开始-->
								<div class="my_cont4">
									<ul id="simpleBuys">
									</ul>
								</div>
								<!--列表结束-->



							</div>



						</div>

					</div>
				</div>
				<!--选项卡结束-->



			</div>
		</div>
		<!--左边结束  -->

		<!--右边开始  -->
		<div class="wrap_right">
			<div class="w_box5">


				<div class="list_tt1">
					<span class="span6">同区域的其他求购信息</span>
				</div>
				<div class="outbox2">


					<div class="detail_list1">
						<ul>
							<s:iterator value="otherWantBuysOfArea">
								<li>
									<div class="wrap_left">
										<span class="showpic3"><img src="<s:property value='image50' />"  /></span>
									</div>
									<div class="wrap_left">
										<div class="my05_cont2">
											<span><a href="wantBuyDetail.htm?wantBuyModel.wantId=<s:property value='wantId' />"><s:property value="goodsName" /></a></span><br />
											<span class="span1">服务费：</span><span class="span18">￥<s:property value="serviceFee"/>
											</span>
										</div>
									</div>
									<div class="clear"></div>
								</li>
							</s:iterator>
						</ul>
					</div>

				</div>


				<div class="blank1"></div>
				<div class="list_tt1">
					<span class="span6">同类别的其他求购信息</span>
				</div>
				<div class="outbox2">


					<div class="detail_list1">
						<ul>
							<s:iterator value="otherWantBuysOfCategory">
								<li>
									<div class="wrap_left">
										<span class="showpic3"><img src="<s:property value='image50' />" /></span>
									</div>
									<div class="wrap_left">
										<div class="my05_cont2">
											<span><a href="wantBuyDetail.htm?wantBuyModel.wantId=<s:property value='wantId' />"><s:property value="goodsName" /></a></span><br />
											<span class="span1">服务费：</span><span class="span18">￥<s:property value="serviceFee"/>
											</span>
										</div>
									</div>
									<div class="clear"></div>
								</li>
							</s:iterator>
						</ul>
					</div>

				</div>



			</div>
		</div>
		<!--右边结束  -->

		<div class="clear"></div>
	</div>

</div>

<!--第2部分结束  -->
<s:include value="/comm/bottom.jsp" />

<SCRIPT type=text/javascript>
	var _wantId = wantId;
	var _userId = userId;
	function invite(wantId, userId){
		_wantId = wantId;
		_userId = userId;
		var userObj = "${sessionScope.user}";
		if(userObj == '' && !bLogin){
			to = 6;
			showLogin();
		}else{
			if (_userId == lUserId) {
				$("#inviteDiv").hide();
				$("#rideBuyDiv").hide();
			}
			else {
				$.ajax( {
					url:'canInvite.htm',
					data:{"inviteModel.wantId":_wantId},
					success:function(json) {
						if (json.ajaxMsg != null) {
							alert(json.ajaxMsg);
						}	
						else {
							window.location.href = "invite.htm?id=" + _wantId;
						}
					}
				});
			}
		}
	};
	
	function rideBuy(wantId, userId) {
		_wantId = wantId;
		_userId = userId;
		var userObj = "${sessionScope.user}";
		if(userObj == '' && !bLogin){
			to = 7;
			showLogin();
		}else{
			if (_userId == lUserId) {
				$("#inviteDiv").hide();
				$("#rideBuyDiv").hide();
			}
			else {
				$.ajax({
					url:'canRideBuy.htm',
					data:{"simpleBuyModel.wantBuyModel.wantId":_wantId},
					success:function(json){
						if (json.ajaxMsg != null) {
							alert(json.ajaxMsg);
						}
						else {
							window.location.href= "rideBuy.htm?id=" + _wantId;
						}
					}
				});
			}
		}
	};

	$(function(){			
	   $(".jqzoom").jqueryzoom({
			xzoom:400,
			yzoom:400,
			offset:10,
			position:"right",
			preload:1,
			lens:1
		});
		$("#spec-list").jdMarquee({
			deriction:"left",
			width:350,
			height:56,
			step:2,
			speed:4,
			delay:10,
			control:true,
			_front:"#spec-right",
			_back:"#spec-left"
		});
		$("#spec-list img").bind("mouseover",function(){
			var src=$(this).attr("src");
			$("#spec-n1 img").eq(0).attr({
				src:src.replace("\/n5\/","\/n1\/"),
				jqimg:src.replace("\/n5\/","\/n0\/")
			});
			$(this).css({
				"border":"2px solid #ff6600",
				"padding":"1px"
			});
		}).bind("mouseout",function(){
			$(this).css({
				"border":"1px solid #ccc",
				"padding":"2px"
			});
		});				
	})
	
	function querySimpleBuys(wantId) {
		setTab('taba',2,2);
		$.ajax({
			url:'querySimpleBuys.htm',
			type:'post',
			data:{"simpleBuyModel.wantBuyModel.wantId":wantId},
			success:showSimpleBuys
		});	
	}
	
	function showSimpleBuys(json) {
		var simpleBuyModels = json.simpleBuyModels;
		if (simpleBuyModels.length == 0) {
			$("#simpleBuys").html("暂无搭车求购记录");
		}
		else {
			var html = "";			
			for (var i = 0; i < simpleBuyModels.length; i++) {
				html += "<li>" + simpleBuyModels[i].ts + "&nbsp;&nbsp;" + simpleBuyModels[i].user.nickName; 
				html += "&nbsp;&nbsp;搭车求购了&nbsp;<strong>" + simpleBuyModels[i].wantBuyModel.goodsName + "</strong>&nbsp;，数量&nbsp;";
				html += simpleBuyModels[i].number + "&nbsp;件</li>";
			}
			$("#simpleBuys").html(html);
		}
	}
</SCRIPT>
